package com.just.gameapp.controller;

import com.just.gameapp.entity.Star;
import com.just.gameapp.service.StarService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zyr
 * @date 2024/6/18 下午3:07
 * @Description
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/stars")
public class StarController {
    @Resource
    private StarService starService;
    @GetMapping("/list")
    public List<Star> getStarList() {
        return starService.list();
    }
    @PostMapping("/add")
    public Object addStar(@ModelAttribute Star star) {
        return starService.save(star);
    }
    @DeleteMapping("/delete/{starId}")
    public Object deleteStar(@PathVariable Integer starId) {
        return starService.removeById(starId);
    }
    @PutMapping("/update")
    public Object updateStar(@ModelAttribute Star star) {
        return starService.updateById(star);
    }
}
